package com.bigflexlib.ds.op
{
	import com.bigflexlib.ds.container.bag.IOWBag;
	import com.bigflexlib.ds.container.bag.IRBag;
	import com.bigflexlib.ds.container.bag.impl.RWDictionaryBag;
	import com.bigflexlib.ds.container.bag.impl.owBag;
	import com.bigflexlib.ds.container.zet.IOWSet;
	import com.bigflexlib.ds.container.zet.impl.owSet;
	import com.bigflexlib.utils.IOperator;
	import com.bigflexlib.utils.BasicTestBase;
	import com.bigflexlib.x.String.StringUtil;




	/**
	 * @private
	 * 
	 */
	public class ContainerUnionOpTest extends BasicTestBase
	{



		public function testGeneral( ):void
		{
		
			var target:IOWBag = owBag( );
		
			var child1:IOWSet = owSet( );
			var child2:IOWSet = owSet( );
			
			var parent:IOWSet = owSet( );			
			
			
			
			var op:IOperator = new ContainerUnionOp( parent, target );
			
			assertTrue( target.compare( s("") ).isEqual );
						
			
			child1.add( "a" );
			parent.add( child1 );
			
			assertTrue( target.compare( s("a") ).isEqual );
			
			
			child1.add( "b" );
			
			assertTrue( target.compare( s("ab") ).isEqual );
			
			
			child2.add( "A" );
			parent.add( child2 );
			child2.add( "B" );
		
			assertTrue( target.compare( s("abAB") ).isEqual );
			
			
			child2.add( "a" );
		
			assertTrue( target.compare( s("aabAB") ).isEqual );
			
		
			child1.remove( "a" );

			assertTrue( target.compare( s("abAB") ).isEqual );
		
			
			parent.remove( child2 );
		
			assertTrue( target.compare( s("b") ).isEqual );

						

			parent.clear( );
			
			assertTrue( target.compare( s("") ).isEqual );

		
		}




		private function s( letters:String ):IRBag
		{
			return new RWDictionaryBag( StringUtil.toCharArray( letters ) );		
		}

		
	}


}
